import Vue from 'vue'
import Vuex from 'vuex'
import menus from "./inc/menus";
import cookies from "vue-cookies";

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        token: ''
    },
    mutations: {
        SET_TOKEN: (state, data) => {
            state.token = data.token
            let userinfo = {username: data.username, user_id: data.id, icon: data.icon, role: data.role}
            cookies.set("token", data.token, '7d')
            cookies.set("userinfo", userinfo, '7d')
        },
    },
    actions: {},
    modules: {
        //添加额外的模块，叫menus
        menus
    }
})
